package cn.matezk.lianlian.model;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import lombok.Data;

import java.util.Calendar;
import java.util.Date;

@Data
public class SimRenew {
    private String appId;
    private String cardSource;
    private String iccid;
    private Date expireDate;
    private Date iccidExpireDate;
    private Integer months;
    private String payno;
    private Date renewTime;

    public Integer getMonths() {
        if (ObjectUtil.isNotNull(months))   return months;
        Calendar c1 = DateUtil.calendar(expireDate);
        Calendar c2 = DateUtil.calendar(iccidExpireDate);
        int m1 = c1.get(Calendar.YEAR) * 12 + c1.get(Calendar.MONTH);
        int m2 = c2.get(Calendar.YEAR) * 12 + c2.get(Calendar.MONTH);
        return m1 - m2;
    }
}
